//==============================================================================
#include "CLight.h"

//==============================================================================
std::vector<CLight> CLight::LightList;

//==============================================================================
CLight::CLight() {
    X = Y = 0;

    R = G = B = Alpha = 1.0f;
}

//==============================================================================
bool CLight::OnLoad(char* File, int X, int Y) {
    if(Tex_Light.OnLoad(File) == false) {
        return false;
    }

    this->X = X;
    this->Y = Y;

    return true;
}

//------------------------------------------------------------------------------
void CLight::OnRender() {
    Tex_Light.Bind();

    glBlendFunc(GL_ONE, GL_ONE);

    glColor4f(R, G, B, Alpha);
    Tex_Light.RenderQuad(X, Y);
    glColor4f(1, 1, 1, 1);

    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}

//==============================================================================
void CLight::SetColor(float R, float G, float B, float Alpha) {
    this->R = R;
    this->G = G;
    this->B = B;

    this->Alpha = Alpha;
}

//==============================================================================
void CLight::AddLight(char* File, int X, int Y) {
    CLight tempLight;

    if(tempLight.OnLoad(File, X, Y) == false) {
        return;
    }

    LightList.push_back(tempLight);
}

//==============================================================================
